package com.vcc.service.service;


import cn.hutool.core.date.DateTime;
import com.alibaba.fastjson2.JSONObject;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import com.vcc.core.model.AmountData;
import com.vcc.core.model.CountData;
import com.vcc.core.model.RateData;
import com.vcc.data.entity.Role;
import com.vcc.data.entity.Transaction;
import com.vcc.service.client.vo.statistics.UserTransactionVo;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;


public interface TransactionService extends IService<Transaction> {

    Boolean existsByTranId(String tranId);

    Boolean existsByChannelTranId(String channelTranId);

    String getTranIdByChannelTranId(String channelTranId);

    Transaction getByChannelTranId(String channelTranId);

    Boolean updateStatusById(Long id, String status);

    Boolean updateStatusByChannelTranId(String channelTranId, String status);

    Boolean updateReversalTran(
            String channelTranId,
            String status,
            BigDecimal settleAmount,
            String settleCurrency,
            Date settleDate,
            Date postDate,
            Boolean hasClear
    );

    Boolean updateRefundTran(
            String channelTranId,
            String status,
            BigDecimal settleAmount,
            String settleCurrency,
            Date settleDate,
            Date postDate,
            Boolean hasClear
    );

    Boolean updateTranSettleData(
            String channelTranId,
            String channelSettleId,
            String settleTranId,
            String status,
            BigDecimal settleAmount,
            String settleCurrency,
            Date settleDate,
            Date postDate,
            Boolean hasClear
    );

    Page<Transaction> paging(Long userId, Role role, Page<Transaction> pageable, Long targetUserId, String status, String type, String cardNumber, String startDate, String endDate, Long userCardId);

    Page<Transaction> paging(
            Long userId,
            Page<Transaction> pageable,
            Long targetUserId,
            String status,
            String type,
            String cardNumber,
            String startDate,
            String endDate,
            Long userCardId,
            Long cardTypeId,
            String channelCode);

    List<UserTransactionVo> sumCount(Long userId, Role role, Date startDate, Date endDate);

    List<UserTransactionVo> sumCount(Long userId, Date startDate, Date endDate);

    List<JSONObject> statistics();

    List<JSONObject> statistics(DateTime startDate, DateTime endDate);

    List<JSONObject> statistics(DateTime startDate, DateTime endDate, Long userId, Long dealerId);

    List<CountData> successCountById(Long userId);

    List<AmountData> successAmountByUserId(Long userId);

    List<RateData> successRateByUserId(Long userId);

    List<JSONObject> cardTypeStatistics(DateTime startDate, DateTime endDate, List<Long> cardTypeIds);

    JSONObject userCardStatistics(DateTime startDate, DateTime endDate, Long userCardId);


    List<Long> listUserCardIdByDate(DateTime startDate, DateTime endDate);
}
